package com.yong.sbd.biz.mybatis.service.impl;

import com.yong.sbd.biz.mybatis.entity.SysUser;
import com.yong.sbd.biz.mybatis.mapper.SysUserMapper;
import com.yong.sbd.biz.mybatis.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.List;

/**
 * 用户服务实现类
 *
 * @author Kang Yong
 * @date 2025/10/24
 * @since 1.0.0
 */
@Service
public class SysUserServiceImpl implements SysUserService {

    @Autowired
    private SysUserMapper userMapper;

    @Override
    public SysUser getUserById(Long id) {
        return userMapper.selectById(id);
    }

    @Override
    public SysUser getUserByUsername(String username) {
        return userMapper.selectByUsername(username);
    }

    @Override
    public List<SysUser> getAllUsers() {
        return userMapper.selectAll();
    }

    @Override
    public boolean saveUser(SysUser user) {
        return userMapper.insert(user) > 0;
    }

    @Override
    public boolean updateUser(SysUser user) {
        return userMapper.update(user) > 0;
    }

    @Override
    public boolean deleteUser(Long id) {
        return userMapper.deleteById(id) > 0;
    }
}